/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PhysicCollection;

import java.awt.event.KeyEvent;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author danh.ngothanh
 */
public class TabPanel extends JTabbedPane implements ChangeListener{    
    BulletPanel bulletpanel;
    GravityPanel gravitypanel;
    AngryBirdsDemo angrybirdsdemo;
    BidaDemo bidademo;
    ReflectPanel reflectpanel;
    ShootingGame2DDemo shooting2dgamedemo;
    private Thread mainthread;
    private int MAIN_TAB;
    public TabPanel(){       
        //addChangeListener(this);
        setTabPlacement(JTabbedPane.BOTTOM);
        bulletpanel = new BulletPanel();
        bulletpanel.init();
        gravitypanel = new GravityPanel();
        gravitypanel.init();
        angrybirdsdemo = new AngryBirdsDemo();
        angrybirdsdemo.init();
        bidademo = new BidaDemo();
        bidademo.init();
        reflectpanel = new ReflectPanel();
        reflectpanel.init();
        shooting2dgamedemo = new ShootingGame2DDemo();
        shooting2dgamedemo.init();


        
    }

    public void addTab(){
        addTab("Line Example",bulletpanel);//0
        addTab("Gravity Example",gravitypanel);//1
        addTab("AngryBirds Demo",angrybirdsdemo);//2
        addTab("Bida Demo",bidademo);//3
        addTab("Shooting Game 2D Demo", shooting2dgamedemo);//4
        addTab("Reflect Demo", reflectpanel);//5
        MAIN_TAB = 2;
        setSelectedIndex(MAIN_TAB);
//        addChangeListener(this);
    }
    public void beginThread(){
        switch(MAIN_TAB){
            case 0:
                mainthread = new Thread(bulletpanel);
                break;
            case 1:
                mainthread = new Thread(gravitypanel);
                break;
            case 2:
                mainthread = new Thread(angrybirdsdemo);
                break;
            case 3:
                mainthread = new Thread(bidademo);
                break;
            case 4:
                mainthread = new Thread(shooting2dgamedemo);
                break;
        }        
        mainthread.start();
    }

    public void keyTyped(KeyEvent e) {
        
    }

    public void keyPressed(KeyEvent e) {
        bulletpanel.keyPressed(e);
        shooting2dgamedemo.keyPressed(e);
    }

    public void keyReleased(KeyEvent e) {
        bulletpanel.keyReleased(e);
        shooting2dgamedemo.keyReleased(e);
    }

    

    public void stateChanged(ChangeEvent e) {
           
    }

}
